package com.suyin.ximoon.controller.system;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.suyin.ximoon.controller.base.BaseController;
import com.suyin.ximoon.model.Lylog;
import com.suyin.ximoon.model.bo.Page;
import com.suyin.ximoon.service.LylogService;
import com.suyin.ximoon.util.Common;
import com.suyin.ximoon.util.Tools;

/**
 * 
 * @author lanyuan 2014-11-19
 * @Email: mmm333zzz520@163.com
 * @version 3.0v
 */
@Controller
@RequestMapping("/log/")
public class LogController extends BaseController {
	@Resource
	private LylogService logService;

	@RequestMapping("list")
	public String listUI(Model model) throws Exception {
		return Common.BACKGROUND_PATH + "/system/log/list";
	}

	@ResponseBody
	@RequestMapping("findByPage")
	public Page findByPage( String pageNow,String pageSize ,String accountName) throws Exception {
		 Page page = new Page();
         if (Tools.notEmpty( pageNow))
         {
             page.setCurrentPage(Integer.parseInt(pageNow));
         }
         if (Tools.notEmpty(pageSize))
         {
             page.setShowCount(Integer.parseInt(pageSize));
         }
         else
         {
             page.setShowCount(20);
         }
         Lylog lylog = new Lylog();
         if (Tools.notEmpty(accountName))
         {
        	 lylog.setAccountName(accountName);
         }
         lylog.setPage(page);
         List<Lylog> list= logService.queryByPage(lylog);
         page.setRecords(list);
		return page;
	}
}